package com.ohc.test;

public class 冒泡 {

    public static void main(String[] args) {
        int[] nums = new int[]{3, 2, 4, 516, 56};
        int temp;
        for (int i = 0; i < nums.length; i++) {
            for (int j = i; j < nums.length - i - 1; j++) {
                if (nums[j] > nums[j + 1]) {
                    temp = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j + 1] = temp;
                }
            }
        }
        for (int num : nums) {
            System.out.println(num);
        }

    }
}
